﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace daq_test_cs
{
    
    public class USBServerWrapper
    {
        public enum DeviceType
        {
            DeviceType_DAQ217,
            DeviceType_DAQ216,
            DeviceType_DAQ207,
            DeviceType_DAQ206,
            DeviceType_DAQ125,
        }

        private const string DllPath = "./libdaq-3.5.8.dll";

        [DllImport(DllPath, CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr USBServer_New(DeviceType device_type);

        [DllImport(DllPath, CallingConvention = CallingConvention.StdCall)]
        public static extern void USBServer_Delete(IntPtr handle);

        [DllImport(DllPath, CallingConvention = CallingConvention.StdCall)]
        public static extern void USBServer_StartSearch(IntPtr handle);

        [DllImport(DllPath, CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr USBServer_GetBusNumbers(IntPtr handle, out byte bus_count);

        [DllImport(DllPath, CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr USBServer_GetDeviceAddresses(IntPtr handle, byte bus_number, out byte device_count);

        [DllImport(DllPath, CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr USBServer_GetClient(IntPtr handle, byte bus_number, byte device_address);
    }
}

